package com.zhangbo.study.designpatternlearning.combination;

import java.util.Iterator;

public class DinerMenu {

    public static final int MAX_ITEMS = 6;

    private int numberOfItems = 0;

    private MenuItem[] menuItems;

    public DinerMenu() {
        menuItems = new MenuItem[MAX_ITEMS];
        addItem("VVegetarian BLT","(Faking) Bacon with lettuce & tomato on whole wheat",true,2.99);
        addItem("BLT","Bacon with lettuce & tomato on whole wheat",false,2.99);
        addItem("Hotdog","A hot dog with saurkraut,relish,onions,topped with cheese",false,3.05);
    }

    public void addItem(String name,String description,boolean vegetarian,double price) {
        MenuItem menuItem = new MenuItem(name,description,vegetarian,price);
        if(numberOfItems >= MAX_ITEMS) {
            System.out.println("Sorry,menu is full!");
        } else {
            menuItems[numberOfItems] = menuItem;
            numberOfItems++;
        }
    }

    public MenuItem[] getMenuItems() {
        return this.menuItems;
    }


    public Iterator<MenuItem> createIterator() {
        return new DinerMenuIterator(this.menuItems);
    }

}
